#include <iostream>

using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='M' || s[i]=='T')
			cnt++;
	}
	cout<<min(cnt+k,(int)s.size())<<endl;
	return 0;
}
